﻿using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace ParticlePlayground
{
	// Token: 0x0200013A RID: 314
	[ExecuteInEditMode]
	public class PlaygroundRecorder : MonoBehaviour
	{
		// Token: 0x06000691 RID: 1681 RVA: 0x0002727C File Offset: 0x0002547C
		public virtual void OnEnable()
		{
			if (this.playgroundSystem == null)
			{
				this.playgroundSystem = base.GetComponent<PlaygroundParticlesC>();
			}
			if (Application.isPlaying && this.recordedFrames == null)
			{
				if (this.recorderData != null)
				{
					this._hasRecorderData = true;
					if (this.multithreading)
					{
						this.LoadAsync();
					}
					else
					{
						this.Load();
					}
				}
				else
				{
					this.recordedFrames = new List<RecordedFrame>();
					this._hasEditedRecordData = true;
				}
			}
			this._hasPlaygroundSystem = (this.playgroundSystem != null);
		}

		// Token: 0x06000692 RID: 1682 RVA: 0x00027318 File Offset: 0x00025518
		public virtual void OnDisable()
		{
			if (!this._hasPlaygroundSystem)
			{
				return;
			}
			this.playgroundSystem.inPlayback = false;
			this.playgroundSystem.calculate = false;
		}

		// Token: 0x06000693 RID: 1683 RVA: 0x00027340 File Offset: 0x00025540
		public virtual bool HasRecordedFrames()
		{
			return this.recordedFrames != null && this.recordedFrames.Count > 0;
		}

		// Token: 0x06000694 RID: 1684 RVA: 0x00027360 File Offset: 0x00025560
		public virtual bool IsRecording()
		{
			return this._isRecording;
		}

		// Token: 0x06000695 RID: 1685 RVA: 0x00027368 File Offset: 0x00025568
		public virtual bool IsReplaying()
		{
			return this._isReplaying;
		}

		// Token: 0x06000696 RID: 1686 RVA: 0x00027370 File Offset: 0x00025570
		public virtual bool IsInPlayback()
		{
			return this._inPlayback;
		}

		// Token: 0x06000697 RID: 1687 RVA: 0x00027378 File Offset: 0x00025578
		public virtual int FrameCount()
		{
			if (this.recordedFrames == null)
			{
				return -1;
			}
			return (this.recordedFrames.Count - 1 >= 0) ? (this.recordedFrames.Count - 1) : 0;
		}

		// Token: 0x06000698 RID: 1688 RVA: 0x000273B0 File Offset: 0x000255B0
		public virtual int GetFrameAtTime(float normalizedTime)
		{
			if (this.recordedFrames == null || this.recordedFrames.Count == 0)
			{
				return 0;
			}
			return Mathf.Clamp(Mathf.FloorToInt((float)(this.recordedFrames.Count - 1) * Mathf.Clamp01(normalizedTime)), 0, this.recordedFrames.Count - 1);
		}

		// Token: 0x06000699 RID: 1689 RVA: 0x00027408 File Offset: 0x00025608
		public virtual float GetFloatingFrameAtTime(float normalizedTime)
		{
			if (this.recordedFrames == null || this.recordedFrames.Count < 1)
			{
				return 0f;
			}
			return (float)(this.recordedFrames.Count - 1) * Mathf.Clamp01(normalizedTime);
		}

		// Token: 0x0600069A RID: 1690 RVA: 0x00027444 File Offset: 0x00025644
		public virtual float GetTimeAtFrame(int frame)
		{
			frame = Mathf.Clamp(frame, 0, this.recordedFrames.Count);
			return (float)frame * 1f / (float)(this.recordedFrames.Count - 1);
		}

		// Token: 0x0600069B RID: 1691 RVA: 0x00027474 File Offset: 0x00025674
		public virtual float GetKeyframeIntervalAtFrame(int frame)
		{
			if (this.recordedFrames == null || frame < 0 || frame >= this.recordedFrames.Count)
			{
				return 0f;
			}
			return this.recordedFrames[frame].keyframeInterval;
		}

		// Token: 0x0600069C RID: 1692 RVA: 0x000274B0 File Offset: 0x000256B0
		public virtual float RecordingStarted()
		{
			return this._recordingStarted;
		}

		// Token: 0x0600069D RID: 1693 RVA: 0x000274B8 File Offset: 0x000256B8
		public virtual float GetLastRecordedFrameTime()
		{
			return this._lastRecordedFrameTime;
		}

		// Token: 0x0600069E RID: 1694 RVA: 0x000274C0 File Offset: 0x000256C0
		public virtual void StartRecording()
		{
			if (this.playgroundSystem == null)
			{
				return;
			}
			this.playgroundSystem.inPlayback = false;
			if (this._isRecording)
			{
				this.StopRecording();
			}
			this._isRecording = true;
			this._isReplaying = false;
			this._inPlayback = false;
			this._recordingStarted = Time.realtimeSinceStartup;
			if (Application.isPlaying)
			{
				base.StartCoroutine(this.RecordInternal(this.keyframeInterval));
			}
		}

		// Token: 0x0600069F RID: 1695 RVA: 0x0002753C File Offset: 0x0002573C
		public virtual void StartRecording(float keyframeInterval)
		{
			this.keyframeInterval = keyframeInterval;
			this.StartRecording();
		}

		// Token: 0x060006A0 RID: 1696 RVA: 0x0002754C File Offset: 0x0002574C
		public virtual void StartRecording(float recordingLength, float keyframeInterval)
		{
			if (this.playgroundSystem == null)
			{
				return;
			}
			base.StartCoroutine(this.StartRecordingInternal(recordingLength, keyframeInterval));
		}

		// Token: 0x060006A1 RID: 1697 RVA: 0x00027570 File Offset: 0x00025770
		public virtual void RecordOneFrame()
		{
			this.RecFrame();
		}

		// Token: 0x060006A2 RID: 1698 RVA: 0x00027578 File Offset: 0x00025778
		public virtual void InsertOneFrame(int frame, FrameType frameType = FrameType.Middle)
		{
			this.InsertRecFrame(frame, frameType);
		}

		// Token: 0x060006A3 RID: 1699 RVA: 0x00027584 File Offset: 0x00025784
		public virtual void StopRecording()
		{
			if (this._isRecording)
			{
				this._isRecording = false;
				this._recordingEndFrame = this.recordedFrames.Count - 1;
				base.CancelInvoke("RecFrame");
				if (this.recordedFrames.Count > 0)
				{
					this._recordingStartFrame = Mathf.Clamp(this._recordingStartFrame, 0, this.recordedFrames.Count);
					this._recordingEndFrame = Mathf.Clamp(this._recordingEndFrame, 0, this.recordedFrames.Count);
					this.recordedFrames[this._recordingStartFrame].frameType = FrameType.Start;
					this.recordedFrames[this._recordingEndFrame].frameType = FrameType.End;
				}
			}
		}

		// Token: 0x060006A4 RID: 1700 RVA: 0x0002763C File Offset: 0x0002583C
		public virtual void ClearRecording()
		{
			this._isReplaying = false;
			this.StopRecording();
			this.StopPlayback();
			this.recordedFrames = null;
			this.recordedFrames = new List<RecordedFrame>();
			if (this.recorderData != null)
			{
				this.recorderData.Clear();
			}
			this._hasEditedRecordData = true;
			this._recordingStartFrame = 0;
			this._recordingEndFrame = 0;
			if (this._hasPlaygroundSystem)
			{
				this.playgroundSystem.inPlayback = false;
				this.playgroundSystem.calculate = false;
			}
		}

		// Token: 0x060006A5 RID: 1701 RVA: 0x000276C4 File Offset: 0x000258C4
		public virtual void Play()
		{
			this.Play(this.playHead, this.playbackSpeed, this.loopPlayback);
		}

		// Token: 0x060006A6 RID: 1702 RVA: 0x000276E0 File Offset: 0x000258E0
		public virtual void Play(float speed)
		{
			this.playbackSpeed = speed;
			this.Play(this.playHead, speed, this.loopPlayback);
		}

		// Token: 0x060006A7 RID: 1703 RVA: 0x000276FC File Offset: 0x000258FC
		public virtual void Play(float fromNormalizedTime, float speed, bool repeat)
		{
			if (!this._hasPlaygroundSystem)
			{
				return;
			}
			if (!this._isReplaying && this.localSpaceOnPlayback)
			{
				this._previousSimulationSpace = this.playgroundSystem.shurikenParticleSystem.simulationSpace;
				this.playgroundSystem.shurikenParticleSystem.simulationSpace = ParticleSystemSimulationSpace.Local;
			}
			this.playgroundSystem.inPlayback = true;
			this.playbackSpeed = speed;
			this.loopPlayback = repeat;
			this.playHead = fromNormalizedTime;
			this._isReplaying = true;
			this.StopRecording();
			this.StartPlayback();
			if (this.playHead >= 1f)
			{
				this.playHead = 0f;
			}
			if (Application.isPlaying)
			{
				base.StartCoroutine(this.PlayRecordedFrames(this.playHead));
			}
		}

		// Token: 0x060006A8 RID: 1704 RVA: 0x000277C0 File Offset: 0x000259C0
		public virtual void Pause()
		{
			if (!this._hasPlaygroundSystem)
			{
				return;
			}
			this.playgroundSystem.inPlayback = true;
			this._isReplaying = false;
			if (this._isRecording)
			{
				this.StopRecording();
			}
			this.StartPlayback();
		}

		// Token: 0x060006A9 RID: 1705 RVA: 0x000277F8 File Offset: 0x000259F8
		public virtual void Stop()
		{
			if (!this._hasPlaygroundSystem)
			{
				return;
			}
			if (this._isReplaying && this.localSpaceOnPlayback)
			{
				this.playgroundSystem.shurikenParticleSystem.simulationSpace = this._previousSimulationSpace;
			}
			this.playgroundSystem.inPlayback = false;
			this._isReplaying = false;
			if (this._isRecording)
			{
				this.StopRecording();
			}
			this.StopPlayback();
		}

		// Token: 0x060006AA RID: 1706 RVA: 0x00027868 File Offset: 0x00025A68
		public virtual void StopAndSerialize()
		{
			if (!this._hasPlaygroundSystem)
			{
				return;
			}
			this.playgroundSystem.inPlayback = false;
			this._isReplaying = false;
			if (this._isRecording)
			{
				this.StopRecording();
				this.Serialize();
			}
			this.StopPlayback();
		}

		// Token: 0x060006AB RID: 1707 RVA: 0x000278A8 File Offset: 0x00025AA8
		public virtual void Serialize()
		{
			if (this._hasRecorderData && this._hasEditedRecordData)
			{
				if (this.multithreading)
				{
					this.recorderData.SerializeAsync(this.recordedFrames);
				}
				else
				{
					this.recorderData.Serialize(this.recordedFrames);
				}
				this._hasEditedRecordData = false;
			}
		}

		// Token: 0x060006AC RID: 1708 RVA: 0x00027904 File Offset: 0x00025B04
		public virtual void Load()
		{
			if (this.recorderData != null)
			{
				this.recordedFrames = this.recorderData.CloneAsRecordedFrames();
				this._hasEditedRecordData = true;
			}
			else
			{
				global::Debug.Log("No Playground Recorder Data to load from!", base.gameObject);
			}
		}

		// Token: 0x060006AD RID: 1709 RVA: 0x00027944 File Offset: 0x00025B44
		public virtual void LoadAsync()
		{
			if (this.recorderData == null)
			{
				global::Debug.Log("No Playground Recorder Data to load from!", base.gameObject);
				return;
			}
			PlaygroundC.RunAsync(delegate()
			{
				this.recordedFrames = this.recorderData.CloneAsRecordedFrames();
				this._hasEditedRecordData = true;
			});
		}

		// Token: 0x060006AE RID: 1710 RVA: 0x0002797C File Offset: 0x00025B7C
		public virtual void Scrub(float normalizedTime)
		{
			if (!this.HasRecordedFrames())
			{
				return;
			}
			if (this._isRecording)
			{
				this.StopRecording();
			}
			if (!this._inPlayback)
			{
				this.StartPlayback();
			}
			if (this.multithreading)
			{
				PlaygroundC.RunAsync(delegate()
				{
					object obj = this.locker;
					lock (obj)
					{
						this.ScrubInternal(normalizedTime);
					}
				});
			}
			else
			{
				this.ScrubInternal(normalizedTime);
			}
		}

		// Token: 0x060006AF RID: 1711 RVA: 0x000279F8 File Offset: 0x00025BF8
		public virtual bool Trim(float leftTime, float rightTime)
		{
			if (this.recordedFrames.Count == 0)
			{
				return false;
			}
			int frameAtTime = this.GetFrameAtTime(leftTime);
			int frameAtTime2 = this.GetFrameAtTime(rightTime);
			bool flag = false;
			if (frameAtTime > 0)
			{
				this.recordedFrames.RemoveRange(0, frameAtTime);
				flag = true;
			}
			if (frameAtTime2 < this.recordedFrames.Count - 1)
			{
				int num = frameAtTime2 - frameAtTime;
				this.recordedFrames.RemoveRange(num, this.recordedFrames.Count - num);
				flag = true;
			}
			if (flag)
			{
				this._hasEditedRecordData = true;
				this.Serialize();
			}
			return flag;
		}

		// Token: 0x060006B0 RID: 1712 RVA: 0x00027A88 File Offset: 0x00025C88
		public virtual void TrimInner(float leftTime, float rightTime)
		{
			if (this.recordedFrames.Count == 0)
			{
				return;
			}
			int frameAtTime = this.GetFrameAtTime(leftTime);
			int frameAtTime2 = this.GetFrameAtTime(rightTime);
			this.recordedFrames.RemoveRange(frameAtTime, frameAtTime2 - frameAtTime);
			this._hasEditedRecordData = true;
			this.Serialize();
		}

		// Token: 0x060006B1 RID: 1713 RVA: 0x00027AD4 File Offset: 0x00025CD4
		public virtual void SetParticleSystemAsCurrentPlayback()
		{
			this.SetParticleSystemAsRecording(this.playHead);
		}

		// Token: 0x060006B2 RID: 1714 RVA: 0x00027AE4 File Offset: 0x00025CE4
		public virtual void SetParticleSystemAsRecording(float normalizedTime)
		{
			if (this.playgroundSystem == null || this._playbackParticles == null)
			{
				return;
			}
			if (this.multithreading)
			{
				PlaygroundC.RunAsync(delegate()
				{
					object obj = this.locker;
					lock (obj)
					{
						this.SetParticleSystemAsRecordingInternal(normalizedTime);
					}
				});
			}
			else
			{
				this.SetParticleSystemAsRecordingInternal(normalizedTime);
			}
		}

		// Token: 0x060006B3 RID: 1715 RVA: 0x00027B50 File Offset: 0x00025D50
		public virtual void RecFrame()
		{
			if (!this._isRecording)
			{
				return;
			}
			if (!this.playgroundSystem.calculate)
			{
				base.CancelInvoke("RecFrame");
				return;
			}
			this._lastRecordedFrameTime = Time.realtimeSinceStartup;
			if (this.playgroundSystem.particleCache != null)
			{
				if (this.recordedFrames == null)
				{
					this.recordedFrames = new List<RecordedFrame>();
				}
				this.recordedFrames.Add(new RecordedFrame(this.playgroundSystem, this.keyframeInterval));
				this._hasEditedRecordData = true;
			}
		}

		// Token: 0x060006B4 RID: 1716 RVA: 0x00027BDC File Offset: 0x00025DDC
		public virtual void InsertRecFrame(int frame, FrameType frameType)
		{
			if (this.playgroundSystem.particleCache != null)
			{
				if (this.recordedFrames == null)
				{
					this.recordedFrames = new List<RecordedFrame>();
				}
				this.recordedFrames.Insert(frame, new RecordedFrame(this.playgroundSystem, this.keyframeInterval));
				this.recordedFrames[frame].frameType = frameType;
				this._hasEditedRecordData = true;
			}
		}

		// Token: 0x060006B5 RID: 1717 RVA: 0x00027C48 File Offset: 0x00025E48
		public virtual void StartPlayback()
		{
			if (!this._inPlayback && this.recordedFrames != null && this.recordedFrames.Count > 0 && this.playgroundSystem != null)
			{
				this._inPlayback = true;
				this.playgroundSystem.calculate = false;
				this.playgroundSystem.inPlayback = true;
				if (this.recordedFrames[0].particles != null)
				{
					this._playbackParticles = this.recordedFrames[0].CloneAsParticles();
				}
				base.StartCoroutine(this.Playback());
			}
		}

		// Token: 0x060006B6 RID: 1718 RVA: 0x00027CE8 File Offset: 0x00025EE8
		public virtual void StopPlayback()
		{
			this._inPlayback = false;
			if (this._hasPlaygroundSystem)
			{
				this.playgroundSystem.calculate = true;
			}
		}

		// Token: 0x060006B7 RID: 1719 RVA: 0x00027D08 File Offset: 0x00025F08
		public virtual void ScrubInternal(float normalizedTime)
		{
			normalizedTime = Mathf.Clamp01(normalizedTime);
			int frameAtTime = this.GetFrameAtTime(normalizedTime);
			if (this.skipInterpolationOnEndFrames && normalizedTime < 1f && this.recordedFrames[frameAtTime].frameType == FrameType.End)
			{
				normalizedTime = Mathf.Clamp01(normalizedTime + (this.GetTimeAtFrame(frameAtTime + 1) - normalizedTime));
				this.playHead = normalizedTime;
				frameAtTime = this.GetFrameAtTime(normalizedTime);
			}
			int num = Mathf.Clamp(frameAtTime + 1, 0, this.recordedFrames.Count);
			int index = Mathf.Clamp(num + 1, 0, this.recordedFrames.Count);
			if (this._playbackParticles == null || this._playbackParticles.Length != this.recordedFrames[frameAtTime].particles.Length)
			{
				if (this.recordedFrames[frameAtTime].particles == null)
				{
					return;
				}
				this._playbackParticles = this.recordedFrames[frameAtTime].CloneAsParticles();
			}
			if (frameAtTime >= this.recordedFrames.Count - 1 || (normalizedTime == 0f && !this.loopPlayback))
			{
				return;
			}
			float num2 = 1f - ((float)num - this.GetFloatingFrameAtTime(normalizedTime));
			for (int i = 0; i < this._playbackParticles.Length; i++)
			{
				if (this.recordedFrames[frameAtTime].particles[i].lifetime < this.recordedFrames[num].particles[i].lifetime)
				{
					Color32 color = (!this.fadeIn) ? default(Color32) : new Color32(this.recordedFrames[frameAtTime].particles[i].color.r, this.recordedFrames[frameAtTime].particles[i].color.g, this.recordedFrames[frameAtTime].particles[i].color.b, 0);
					this._playbackParticles[i].position = Vector3.Lerp(this.recordedFrames[frameAtTime].particles[i].sourcePosition, this.recordedFrames[num].particles[i].position, num2);
					this._playbackParticles[i].startSize = Mathf.Lerp(this.sizeIn ? 0f : this.recordedFrames[frameAtTime].particles[i].startingSize, this.recordedFrames[num].particles[i].size, num2);
					this._playbackParticles[i].startColor = Color.Lerp(this.fadeIn ? color : this.recordedFrames[frameAtTime].particles[i].color, this.recordedFrames[num].particles[i].color, num2);
					this._playbackParticles[i].rotation = Mathf.Lerp(this.recordedFrames[num].particles[i].rotation - this.recordedFrames[index].particles[i].rotation * num2, this.recordedFrames[num].particles[i].rotation, num2);
				}
				else
				{
					this._playbackParticles[i].position = Vector3.Lerp(this.recordedFrames[frameAtTime].particles[i].position, this.recordedFrames[num].particles[i].position, num2);
					this._playbackParticles[i].startSize = Mathf.Lerp(this.recordedFrames[frameAtTime].particles[i].size, this.recordedFrames[num].particles[i].size, num2);
					this._playbackParticles[i].startColor = Color.Lerp(this.recordedFrames[frameAtTime].particles[i].color, this.recordedFrames[num].particles[i].color, num2);
					this._playbackParticles[i].rotation = Mathf.Lerp(this.recordedFrames[frameAtTime].particles[i].rotation, this.recordedFrames[num].particles[i].rotation, num2);
					this._playbackParticles[i].lifetime = Mathf.Lerp(this.recordedFrames[frameAtTime].particles[i].lifetime, this.recordedFrames[num].particles[i].lifetime, num2);
				}
			}
		}

		// Token: 0x060006B8 RID: 1720 RVA: 0x00028268 File Offset: 0x00026468
		public virtual void SetParticleSystemAsRecordingInternal(float normalizedTime)
		{
			normalizedTime = Mathf.Clamp01(normalizedTime);
			int frameAtTime = this.GetFrameAtTime(normalizedTime);
			int num = Mathf.Clamp(frameAtTime + 1, 0, this.recordedFrames.Count - 1);
			float t = 1f - ((float)num - this.GetFloatingFrameAtTime(normalizedTime));
			float timeStamp = this.recordedFrames[frameAtTime].timeStamp;
			float globalTime = PlaygroundC.globalTime;
			int num2 = this.playgroundSystem.playgroundCache.position.Length;
			for (int i = 0; i < this._playbackParticles.Length; i++)
			{
				this.playgroundSystem.playgroundCache.position[i % num2] = Vector3.Lerp(this.recordedFrames[frameAtTime].particles[i].position, this.recordedFrames[num].particles[i].position, t);
				this.playgroundSystem.playgroundCache.velocity[i % num2] = Vector3.Lerp(this.recordedFrames[frameAtTime].particles[i].velocity, this.recordedFrames[num].particles[i].velocity, t);
				this.playgroundSystem.playgroundCache.size[i % num2] = Mathf.Lerp(this.recordedFrames[frameAtTime].particles[i].size, this.recordedFrames[num].particles[i].size, t);
				this.playgroundSystem.playgroundCache.color[i % num2] = Color.Lerp(this.recordedFrames[frameAtTime].particles[i].color, this.recordedFrames[num].particles[i].color, t);
				this.playgroundSystem.playgroundCache.rotation[i % num2] = Mathf.Lerp(this.recordedFrames[frameAtTime].particles[i].rotation, this.recordedFrames[num].particles[i].rotation, t);
				this.playgroundSystem.playgroundCache.life[i % num2] = Mathf.Lerp(this.recordedFrames[frameAtTime].particles[i].playgroundLife, this.recordedFrames[num].particles[i].playgroundLife, t);
				this.playgroundSystem.playgroundCache.lifetimeSubtraction[i % num2] = Mathf.Lerp(this.recordedFrames[frameAtTime].particles[i].playgroundLifetimeSubtraction, this.recordedFrames[num].particles[i].playgroundLifetimeSubtraction, t);
				this.playgroundSystem.playgroundCache.birth[i % num2] = globalTime + (this.recordedFrames[frameAtTime].particles[i].playgroundStartLifetime - timeStamp);
				this.playgroundSystem.playgroundCache.death[i % num2] = globalTime + (this.recordedFrames[frameAtTime].particles[i].playgroundEndLifetime - timeStamp);
			}
			this.playgroundSystem.localTime = globalTime;
			this.playgroundSystem.LastTimeUpdated = globalTime;
			this.playgroundSystem.LocalDeltaTime = 0.001f;
			this.playgroundSystem.cameFromNonCalculatedFrame = false;
			this.playgroundSystem.cameFromNonEmissionFrame = false;
			this.playgroundSystem.loopExceeded = false;
			this.playgroundSystem.loopExceededOnParticle = -1;
			this.playgroundSystem.hasActiveParticles = true;
			this.StopAndSerialize();
		}

		// Token: 0x060006B9 RID: 1721 RVA: 0x00028658 File Offset: 0x00026858
		public virtual IEnumerator StartRecordingInternal(float recordingLength, float keyframeInterval)
		{
			this._isReplaying = false;
			this._inPlayback = false;
			this._isRecording = true;
			this.playgroundSystem.inPlayback = false;
			base.StartCoroutine(this.RecordInternal(keyframeInterval));
			yield return new WaitForSeconds(recordingLength);
			this.StopRecording();
			yield break;
		}

		// Token: 0x060006BA RID: 1722 RVA: 0x00028690 File Offset: 0x00026890
		public virtual IEnumerator RecordInternal(float keyframeInterval)
		{
			this._recordingStartFrame = ((this.recordedFrames.Count <= 0) ? 0 : (this.recordedFrames.Count - 1));
			while (this._isRecording)
			{
				this.RecFrame();
				yield return new WaitForSeconds(keyframeInterval);
			}
			yield break;
		}

		// Token: 0x060006BB RID: 1723 RVA: 0x000286BC File Offset: 0x000268BC
		public virtual IEnumerator Playback()
		{
			while (this._inPlayback)
			{
				if (this._playbackParticles != null)
				{
					this.playgroundSystem.shurikenParticleSystem.SetParticles(this._playbackParticles, this._playbackParticles.Length);
				}
				yield return null;
			}
			yield break;
		}

		// Token: 0x060006BC RID: 1724 RVA: 0x000286D8 File Offset: 0x000268D8
		public virtual IEnumerator PlayRecordedFrames(float fromNormalizedTime)
		{
			float t = fromNormalizedTime;
			while (this._isReplaying)
			{
				t += this.playbackSpeed / ((float)this.FrameCount() * this.keyframeInterval) * Time.deltaTime;
				if (t > 1f)
				{
					t = 1f;
				}
				else if (t < 0f)
				{
					t = 0f;
				}
				this.Scrub(t);
				if (t == 1f)
				{
					if (this.loopPlayback)
					{
						t = 0f;
					}
					else
					{
						this._isReplaying = false;
					}
				}
				else if (t == 0f)
				{
					if (this.loopPlayback)
					{
						t = 1f;
					}
					else
					{
						this._isReplaying = false;
					}
				}
				this.playHead = t;
				yield return null;
			}
			yield break;
		}

		// Token: 0x040006B4 RID: 1716
		public bool multithreading = true;

		// Token: 0x040006B5 RID: 1717
		public float keyframeInterval = 0.1f;

		// Token: 0x040006B6 RID: 1718
		public float playbackSpeed = 1f;

		// Token: 0x040006B7 RID: 1719
		public float playHead;

		// Token: 0x040006B8 RID: 1720
		public bool loopPlayback = true;

		// Token: 0x040006B9 RID: 1721
		public bool fadeIn = true;

		// Token: 0x040006BA RID: 1722
		public bool sizeIn = true;

		// Token: 0x040006BB RID: 1723
		public bool skipInterpolationOnEndFrames = true;

		// Token: 0x040006BC RID: 1724
		public bool localSpaceOnPlayback = true;

		// Token: 0x040006BD RID: 1725
		[HideInInspector]
		public PlaygroundParticlesC playgroundSystem;

		// Token: 0x040006BE RID: 1726
		[HideInInspector]
		public global::PlaygroundRecorderData recorderData;

		// Token: 0x040006BF RID: 1727
		[NonSerialized]
		public List<RecordedFrame> recordedFrames;

		// Token: 0x040006C0 RID: 1728
		protected bool _inPlayback;

		// Token: 0x040006C1 RID: 1729
		protected bool _isReplaying;

		// Token: 0x040006C2 RID: 1730
		protected bool _isRecording;

		// Token: 0x040006C3 RID: 1731
		protected bool _hasRecorderData;

		// Token: 0x040006C4 RID: 1732
		protected bool _hasPlaygroundSystem;

		// Token: 0x040006C5 RID: 1733
		protected bool _hasEditedRecordData;

		// Token: 0x040006C6 RID: 1734
		protected float _recordingStarted;

		// Token: 0x040006C7 RID: 1735
		protected float _lastRecordedFrameTime;

		// Token: 0x040006C8 RID: 1736
		protected int _recordingStartFrame;

		// Token: 0x040006C9 RID: 1737
		protected int _recordingEndFrame;

		// Token: 0x040006CA RID: 1738
		protected ParticleSystem.Particle[] _playbackParticles;

		// Token: 0x040006CB RID: 1739
		protected ParticleSystemSimulationSpace _previousSimulationSpace;

		// Token: 0x040006CC RID: 1740
		protected object locker = new object();
	}
}
